home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / files.swg / 0079_Locking Parts of Files.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-09-04  |  888 b   |  23 lines

  1. {
  2. > Does anyone know how to lock parts of a file in pascal?  I'm working on JAM
  3. > message base support, and I need to know how to lock it (and check if it's
  4. > locked, etc).  Example code appreciated. (I have to lock the first byte of
  5. > a file.  How exactly would I go about doing this?)
  6. }
  7.  
  8. function FLock(Lock:byte; Handle: Word; Pos,Len: LongInt): Word; Assembler;
  9. ASM
  10.   mov   AL,Lock   { subfunction 0: lock region   }
  11.                   { subfunction 1: unlock region }
  12.   mov   AH,$5C    { DOS function $5C: FLOCK    }
  13.   mov   BX,Handle { put FileHandle in BX       }
  14.   les   DX,Pos
  15.   mov   CX,ES     { CX:DX begin position       }
  16.   les   DI,Len
  17.   mov   SI,ES     { SI:DI length lockarea      }
  18.   int   $21       { Call DOS ...               }
  19.   jb    @End      { if error then return AX    }
  20.   xor   AX,AX     { else return 0              }
  21.  @End:
  22. end {FLock};
  23.